package com.olympia.myapp.util;

import java.util.Timer;
import java.util.TimerTask;

import android.os.Handler;

public class WaitingReminder {
	ControlListener control;
	TimerTask mTimerTask;
	final Handler handler;
	Timer timer;
	int maxSecond = 60;

	public WaitingReminder(ControlListener ctr) {
		control = ctr;
		timer = new Timer();
		handler = new Handler();
	}

	public void start(int second) {
		maxSecond = second;
		mTimerTask = new TimerTask() {
			public void run() {
				handler.post(new Runnable() {
					public void run() {
						control.runTask();
						mTimerTask.cancel();
					}
				});
			}
		};
		// public void schedule (TimerTask task, long delay, long period)
		timer.schedule(mTimerTask, maxSecond); //
	}

}